<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/5/30
  Time: 12:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script src="${pageContext.request.contextPath}/js/jquery-1.8.3.js"></script>
    <script src="${pageContext.request.contextPath}/js/jquery.form.js"></script>

    <script>
        function submitImage(){
            alert("submit");
            var options={
                type:'post',
                data:{username:'yc'},
                dataType:'json',
                url:'${pageContext.request.contextPath}/upload/itemspic.do',
                success:function (respData) {
                    ${'#pic'}.attrHandle('src',respData.imgUrl);
                    ${'#hiddenPic'}.value(respData.imgUrl);
                }
            }
            ${"#itemsForm"}.ajaxSubmit(options);
        }
    </script>
    <title>upload</title>
</head>
<body>
<form id="itemsForm" action="${pageContext.request.contextPath}/items/update.do" method="post">
<table border="1">
    <tr>
        <td>名称</td>
        <td>
            <input type="text" name="name" value="uuid2">
            <input type="hidden" name="id" value="1">
        </td>
    </tr>
    <td>价格</td>
    <td><input type="text" name="price" value="价格"></td>
    </tr>
    <tr>
        <td>描述</td>
        <td><textarea  cols="20" rows="5" name="detail">描述</textarea> </td>
    </tr>
    <tr>
        <td>图片</td>
        <td>
            <img id="pic" src="${items.pic}" width="100px" heigth="100px">
            <input type="file" name="itemspic1" onchange="submitImage();">
            <input id="hiddenPic" type="hidden" name="pic" value="${items.pic}">
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <input type="submit" value="更新"/>
        </td>
    </tr>
</table>
</form>
</body>
</html>
